package com.red.star.wechat.data.entity;


import lombok.Data;

import javax.persistence.Table;
import javax.persistence.Transient;
import java.util.Date;

/**
 * @Author: Yenan
 * @Description: B端，C端用户表
 * @Date: Created in 15:54 2018/1/30
 */
@Data
@Table(name = "t_fans")
public class Fans extends BaseEntity {

    private String nickname;

    private String openId;

    /**
     * 用户头像
     */
    private String avatarUrl;

    /**
     * 用户的性别，值为1时是男性，值为2时是女性，值为0时是未知
     */
    private Integer gender;

    private String city;

    private String province;

    private String country;

    private String language;


    /**
     * 会员id（导购员也是会员）
     */
    private String vipOpenId;

    /**
     * 用户开发平台唯一id
     */
    private String unionId;

    /**
     * 0:用户、1:员工
     */
    private Integer type;

    private String displayName;

    @Transient
    private Date date;

    /**
     * 导购员名字
     */
    @Transient
    private String name;

    /**
     * 短信提醒开关：1打开 0关闭
     */
    private Integer smsStatus;

    /**
     * 注册回显姓名
     * */
    private String registerName;

    /**
     * 注册回显手机号
     * */
    private String mobile;

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        if (!super.equals(o)) return false;

        Fans fans = (Fans) o;

        if (getId() != null ? !getId().equals(fans.getId()) : fans.getId() != null) return false;
        if (nickname != null ? !nickname.equals(fans.nickname) : fans.nickname != null) return false;
        if (openId != null ? !openId.equals(fans.openId) : fans.openId != null) return false;
        if (avatarUrl != null ? !avatarUrl.equals(fans.avatarUrl) : fans.avatarUrl != null) return false;
        if (gender != null ? !gender.equals(fans.gender) : fans.gender != null) return false;
        if (city != null ? !city.equals(fans.city) : fans.city != null) return false;
        if (province != null ? !province.equals(fans.province) : fans.province != null) return false;
        if (country != null ? !country.equals(fans.country) : fans.country != null) return false;
        if (language != null ? !language.equals(fans.language) : fans.language != null) return false;
        if (vipOpenId != null ? !vipOpenId.equals(fans.vipOpenId) : fans.vipOpenId != null) return false;
        if (unionId != null ? !unionId.equals(fans.unionId) : fans.unionId != null) return false;
        if (type != null ? !type.equals(fans.type) : fans.type != null) return false;
        return  (date != null ? date.equals(fans.date) : fans.date == null);
    }

    @Override
    public int hashCode() {
        int result = super.hashCode();
        result = 31 * result + (getId() != null ? getId().hashCode() : 0);
        result = 31 * result + (nickname != null ? nickname.hashCode() : 0);
        result = 31 * result + (openId != null ? openId.hashCode() : 0);
        result = 31 * result + (avatarUrl != null ? avatarUrl.hashCode() : 0);
        result = 31 * result + (gender != null ? gender.hashCode() : 0);
        result = 31 * result + (city != null ? city.hashCode() : 0);
        result = 31 * result + (province != null ? province.hashCode() : 0);
        result = 31 * result + (country != null ? country.hashCode() : 0);
        result = 31 * result + (language != null ? language.hashCode() : 0);
        result = 31 * result + (vipOpenId != null ? vipOpenId.hashCode() : 0);
        result = 31 * result + (unionId != null ? unionId.hashCode() : 0);
        result = 31 * result + (type != null ? type.hashCode() : 0);
        result = 31 * result + (date != null ? date.hashCode() : 0);
        return result;
    }
}
